package com.qfedu.mesadmin.dev.count.controller;

import com.qfedu.mes.common.CommonResult;
import com.qfedu.mes.common.PageVO;
import com.qfedu.mes.entity.dev.DeviceLed;
import com.qfedu.mesadmin.dev.count.vo.DevTypeNameVO;
import com.qfedu.mesadmin.dev.count.vo.WorkShopVO;
import com.qfedu.mesadmin.dev.count.params.SearchsParam;
import com.qfedu.mesadmin.dev.count.service.DeviceLedService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/dev/led")
public class DeviceLedController {
    @Resource
    private DeviceLedService deviceLedService;
    @GetMapping("/page")
    public CommonResult pageList(SearchsParam param){
        PageVO<DeviceLed> deviceLedPageVO = deviceLedService.pageList(param);
        return CommonResult.success(deviceLedPageVO);
    }
    @PostMapping("/add")
    public CommonResult addDevLed(@RequestBody DeviceLed deviceLed){
        deviceLedService.addDevLed(deviceLed);
        return CommonResult.success();
    }
    @GetMapping("/create/code")
    public CommonResult createDevCode(){
        String s = deviceLedService.devCodes();
        System.out.println(s);
        return CommonResult.success(s);
    }
    @GetMapping("/workshop/list")
    public CommonResult workshopList(){
        List<WorkShopVO> workShopVOS = deviceLedService.workshopList();
        return CommonResult.success(workShopVOS);
    }

    @GetMapping("/type/list")
    public CommonResult devTypeNameList(){
        List<DevTypeNameVO> devTypeNameVOS = deviceLedService.devTypeNameList();
        return CommonResult.success(devTypeNameVOS);
    }
    @GetMapping("/info")
    public CommonResult selectInfo(Integer id){
        DeviceLed deviceLed = deviceLedService.selectInfo(id);
        return CommonResult.success(deviceLed);
    }
    @PostMapping("/update")
    public CommonResult updateDevLed(@RequestBody DeviceLed deviceLed){
        deviceLedService.updateDevLed(deviceLed);
        return CommonResult.success();
    }
    @PostMapping("/delete/batch")
    public CommonResult deleteBatch(@RequestBody List<Integer> ids){
        deviceLedService.deleteBatch(ids);
        return CommonResult.success();
    }
}
